/*=========================================================================
| KCardDAV
|--------------------------------------------------------------------------
| (c) 2010  Kumaran Santhanam
|
| This project is released under the GNU General Public License.
| Please see the file COPYING for more details.
|--------------------------------------------------------------------------
| Main interface to the KResource system.
 ========================================================================*/

/*=========================================================================
| INCLUDES
 ========================================================================*/

#include "preferences.h"
#include "common.h"

#include <kabc/resourcecached.h>
#include <kdemacros.h>

#ifndef KCARDDAV_RESOURCE_H
#define KCARDDAV_RESOURCE_H

class QMutex;

namespace KABC {

/*=========================================================================
| CLASS
 ========================================================================*/

/**
 * This class provides a resource for accessing calendars via CardDAV protocol.
 */
class KDE_EXPORT ResourceCardDav : public ResourceCached {
    Q_OBJECT
public:
    ResourceCardDav();
    explicit ResourceCardDav( const KConfigGroup &group );
    virtual ~ResourceCardDav();

    void readConfig( const KConfigGroup &group );
    void writeConfig( KConfigGroup &group );

    /**
     * @return This resource preferences.
     */
    CardDavPrefs* prefs();

    /**
     * @return This resource preferences.
     */
    const CardDavPrefs* prefs() const;

    virtual Ticket* requestSaveTicket();
    virtual void releaseSaveTicket( Ticket* ticket );

    virtual bool load();
    virtual bool asyncLoad();

    virtual bool save( Ticket* ticket );
    virtual bool asyncSave( Ticket *ticket );

    QMutex* mutex() const;

private slots:
    void onLoadingFinished();
    void onSavingFinished();

private:
    DECLARE_PIMPL(ResourceCardDav)
};

} // namespace

#endif

